<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 */
class AuthWxStudy extends Model
{
    //
    public function wxStudy(){
        return $this->belongsTo(Learn::class,'learn_id');
    }

    public static function findWxStduy($id,$category){
        $res = self::where(['unit_id'=>$id])->select()->toArray();

        if(empty($res)){
            $aaa = $category->getParent($id);

            if(!empty($aaa)){
                $res = self::findWxStduy($aaa[0]['id'],$category);
            }
        }
        return $res;
    }
}
